Skip to main content

Convert

Convert an amount from one currency to another using the current rate for the requesting Merchant. The conversion uses the same rate as the Get FX Rate API, within the validity period of that quote.

The direction (and therefore which rate is applied) is derived from the order of from_currency and to_currency:

  • Converting a foreign currency → VND (the customer sells the foreign currency) applies the bid rate.
  • Converting VND → a foreign currency (the customer buys the foreign currency) applies the ask rate.

The applied side is returned in rate_type, and the response carries the same quote_code so the quote can be reconciled (and, in a later phase, locked).

Path

  • URL: /cb-core/api/v1/fx/convert
  • Method: POST
  • Description: Convert an amount between two currencies using the current rate.

Request

Request table

ParamsData TypeRequiredDescription
request_idstring(50)YesUnique code that identifies the request. Suggested format: MerchantCode + BK + YYYYMMDD + UniqueId
request_timestring(19)YesTime the Merchant sends the request. Format: YYYY-MM-DD HH:MM:SS
merchant_codestring(20)YesMerchant code provided by Baokim before integration
from_currencystring(10)YesThe currency being converted from (e.g. USD). Only one currency code is allowed
to_currencystring(10)YesThe currency being converted to (e.g. VND). Only one currency code is allowed
amountdecimal(18,2)YesThe amount, expressed in from_currency, to be converted

Request Example

{
"request_id": "MERCHANT1234BK202606053",
"request_time": "2026-06-05 10:15:30",
"merchant_code": "MERCHANT1234",
"from_currency": "USD",
"to_currency": "VND",
"amount": 1000.00
}

Response

Response Table

ParamsData TypeRequiredDescription
response_codeint(4)YesResult code from Baokim, as per the Error Codes table
response_messagestring(200)YesDescription of the result code
merchant_codestring(20)YesMerchant code provided by Baokim before integration
dataObjectYesConversion result

Data Object Structure (inside data)

ParamsData TypeDescription
currency_pairstring(10)Currency pair used for the conversion, in BASE/QUOTE format (e.g. USD/VND)
from_currencystring(10)The currency converted from
to_currencystring(10)The currency converted to
amountdecimal(18,2)The input amount, expressed in from_currency
converted_amountdecimal(18,2)The resulting amount, expressed in to_currency
ratedecimal(18,4)The applied rate (VND per 1 unit of the foreign currency)
rate_typestring(3)The side applied: bid or ask
quote_codestring(50)Quote code for this rate. Used for reconciliation and reserved for rate-lock
last_updatedstring(19)Time the rate was last refreshed. Format: YYYY-MM-DD HH:MM:SS
valid_untilstring(19)Time until which the quote is valid. May be null in the current phase

Response Example

{
"response_code": 200,
"response_message": "Success",
"merchant_code": "MERCHANT1234",
"data": {
"currency_pair": "USD/VND",
"from_currency": "USD",
"to_currency": "VND",
"amount": 1000.00,
"converted_amount": 26450000.00,
"rate": 26450.0000,
"rate_type": "bid",
"quote_code": "FXQ20260605101530USDVND0001",
"last_updated": "2026-06-05 10:15:00",
"valid_until": "2026-06-05 10:16:00"
}
}

Error Code

Response CodeResponse Message
200Success
101System Error
110Merchant Code Invalid
120Invalid Signature
404Currency Pair Not Supported
422Validation Error
423FX Rate Not Available
429Too Many Requests